package org.example.springcioud.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.springcioud.entities.CommonResult;
import org.example.springcioud.entities.Payment;
import org.example.springcioud.service.impl.PaymentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @BelongsProject: Spring_Cloud
 * @BelongsPackage: org.example.springcioud.controller
 * @Author:Mr.Yang
 * @CreateTime: 2020-10-17 10:51
 * @Description: 支付控制层
 **/
@RestController
@Slf4j
public class PaymentController {
    @Resource
    private PaymentService paymentService;

    @PostMapping(value = "payment/create")
    public CommonResult create (@RequestBody  Payment payment){
        int   result=paymentService.create(payment);
        log.info("********插入结果"+result);
        return (result>0)? new CommonResult(200,"插入成功",result): new CommonResult(400,"插入失败",result);

    }
    @GetMapping(value = "payment/get/{id}")
    public CommonResult getPaymentById (@PathVariable Long id ){
        System.out.println("12121ttt"+id);
        Payment   payment=paymentService.getPaymentById(id);
        log.info("********返回结果"+payment);
        return (payment!=null)? new CommonResult(200,"查询成功",payment): new CommonResult(400,"没有对应记录",null);

    }


}
